import Vue from "vue"
import Router from "vue-router"

//引入一级组件
import DashBoard from './../views/dashboard/Dashboard'
//懒加载，需要用到该组件才会引入该组件

const Home = ()=>import('./../views/home/Home.vue');
const Category = ()=>import('./../views/category/Category.vue');
const Cart = ()=>import('./../views/cart/Cart.vue');
const Xiangqing = ()=>import('./../views/xiangqing/Xiangqing.vue');
const ContentView = ()=>import('./../views/category/components/ContentView.vue');
//用户中心
const Mine = ()=>import('./../views/mine/Mine.vue');
const UserCenter=()=> import('./../views/mine/children/UserCenter');
const MyOrders=()=>import('./../views/mine/children/MyOrders');
const DzfOrder=()=>import('./../views/mine/children/DzfOrder');
const DfhOrder=()=>import('./../views/mine/children/DfhOrder');
const YfhOrder=()=>import('./../views/mine/children/YfhOrder');
const YwcOrder=()=>import('./../views/mine/children/YwcOrder');
const UserInfo=()=>import('./../views/mine/children/UserInfo');
const Pay=()=>import('./../views/mine/children/children/Pay');
const Detail=()=>import('./../views/mine/children/children/Detail');
const CaiGouYuan=()=>import('./../views/mine/children/children/CaiGouYuan');
const UpdateUserName=()=>import('./../views/mine/children/children/UpdateUserName');
const UpdateUserZH=()=>import('./../views/mine/children/children/UpdateUserZH');
const UpdatePasswd=()=>import('./../views/mine/children/children/UpdatePasswd');
const UpdatePhone=()=>import('./../views/mine/children/children/UpdatePhone');
const Gui=()=>import('./../views/mine/children/Gui');
const Service=()=>import('./../views/mine/children/Service');
const CaigouList=()=>import('./../views/mine/children/CaigouList');
const MyCaigouList=()=>import('./../views/mine/children/MyCaigouList');
const YbGui=()=>import('./../views/mine/children/children/YbGui');
const XhGui=()=>import('./../views/mine/children/children/XhGui');
const CaigouDetail=()=>import('./../views/mine/children/children/CaigouDetail');
const MyCaigouDetail=()=>import('./../views/mine/children/children/MyCaigouDetail');
 const PaySuccess=()=>import('./../views/mine/children/children/children/PaySuccess');
 const CaiGouYuanSuc=()=>import('./../views/mine/children/children/children/CaiGouYuanSuc');
// 引入组件相关
const Order=()=>import('./../views/order/Order.vue');
const Success=()=>import('./../views/order/children/Success.vue');
const AddAddress=()=>import('./../views/order/children/children/AddAddress.vue');
const EditAddress=()=>import('./../views/order/children/children/EditAddress.vue');

//引入登录
const Login=()=>import('./../views/login/Login.vue');
const Regist=()=>import('./../views/regist/Regist.vue');

Vue.use(Router);

export default new Router({
	routes:[
        {path:'/',redirect:'/dashboard'},
         
        {
            path:'/dashboard',
            name:'dashboard',
            component:DashBoard,
            children:[
                 {path:'/dashboard',redirect:'/dashboard/home'},
                 {path:'home',name:'home',component:Home,meta:{keepAlive:true},

                 }, 
                 {path:'category',redirect:'category/contentView/0'},
                 {
                     path:'category',
                     name:'category',
                     component:Category,
                     meta:{keepAlive:true},
                     children:[
                        {path:'contentView/:sort',name:'contentView',component:ContentView},
                     ]
                 },
             
                 {path:'cart',name:'cart',component:Cart},
                 { 
                    path:'mine',
                    name:'mine',
                    component:Mine,
                    children:[
                       {path:'UserCenter',component:UserCenter}, //用户中心
                       {
                          path:'MyOrders',
                          name:'MyOrders',
                          component:MyOrders,
                          children:[
                             { 
                                 path:'pay',
                                 name:'pay',
                                 component:Pay,
                                 children:[ {path:'paysuccess',name:'paysuccess',component:PaySuccess}] //付款成功页面     
                             }, //付款页面
                             {
                                  path:'detail',
                                  name:'detail',
                                  component:Detail,
                             }, //订单详情页面
                          ]
                      }, //我的订单
                      {path:'DzfOrder',name:'DzfOrder',component:DzfOrder}, ///待支付订单
                      {path:'DfhOrder',name:'DfhOrder',component:DfhOrder}, ///待发货订单
                      {path:'YfhOrder',name:'YfhOrder',component:YfhOrder}, ///待已发货订单
                      {path:'YwcOrder',name:'YwcOrder',component:YwcOrder}, ///待已完成订单
                       {
                        path:'UserInfo',
                        name:'UserInfo',
                        component:UserInfo,
                        children:[
                             { 
                               path:'CaiGouYuan',
                               name:'CaiGouYuan',
                               component:CaiGouYuan,
                               children:[ { path:'CaiGouYuanSuc',name:'CaiGouYuanSuc',component:CaiGouYuanSuc}] //采购员申请成功页面
                              },//采购员申请
                             {path:'UpdateUserName',name:'UpdateUserName',component:UpdateUserName},//用户名修改
                             {path:'UpdateUserZH',name:'UpdateUserZH',component:UpdateUserZH},//用户账号修改
                             {path:'UpdatePasswd',name:'UpdatePasswd',component:UpdatePasswd},//修改密码
                             {path:'UpdatePhone',name:'UpdatePhone',component:UpdatePhone},//修改手机号码
                         ]
                        },//个人资料
                        {
                          path:'Gui',
                          name:'Gui',
                          component:Gui,
                          children:[
                              {path:'YbGui',name:'YbGui',component:YbGui},//一般密码柜
                              {path:'XhGui',name:'XhGui',component:XhGui},//鲜活密码柜
                          ]
                          },//我的投放柜
                          {path:'Service',name:'Service',component:Service},  //联系客服
                          {
                             path:'CaigouList',
                             name:'CaigouList',
                             component:CaigouList,
                             children:[
                                   {path:'CaigouDetail',name:'CaigouDetail',component:CaigouDetail} //采购详情页
                             ]
                          },//采购列表
                          {
                             path:'MyCaigouList',
                             name:'MyCaigouList',
                             component:MyCaigouList,
                             children:[
                                   {path:'MyCaigouDetail',name:'MyCaigouDetail',component:MyCaigouDetail} //我的采购详情页
                             ]   
                          }//我的采购

                    ]
                },
                {path:'xiangqing',name:'xiangqing',component:Xiangqing}
            ]
        },
                  

        {
            path:'/confirmOrder',
            name:'order',
            component:Order,
            children:[
                {path:'success',name:'success',component:Success} //订单提交成功
           ]
        },

        {path:'/login',name:'login',component:Login},
        {path:'/regist',name:'regist',component:Regist}


	]
})